using System;

namespace Scenario.Modules.DM.DataModel
{
	public class XMLDocumentTemplate : XMLDocumentBase
	{
		private const string IDFORMAT_ATTRIBUTE = "IdFormat";
		//modified by e.leano for new version of DM: step 3
		private const string DOCUMENT_STORAGE_ATTRIBUTE = "DocumentStorage";

		private string sIdFormat;
		//modified by e.leano for new version of DM: step 3
		private string sDocumentStorage;

		public XMLDocumentTemplate() : base()
		{
			this.Init();
		}

		public XMLDocumentTemplate(System.Xml.XmlNode node) : base(node)
		{
			this.Parse(node);
		}

		public string IdFormat
		{
			get { return sIdFormat;}
			set { sIdFormat = value;}
		}
		
		//modified by e.leano for new version of DM: step 3
		public string DocumentStorage
		{
			get { return sDocumentStorage;}
			set { sDocumentStorage = value;}
		}

		override public void Init()
		{
			base.Init();

			sIdFormat = string.Empty;
			//modified by e.leano for new version of DM: step 3
			sDocumentStorage= string.Empty;
		}

		override public void Parse(System.Xml.XmlNode node2Parse)
		{
			//only Parse because Init methods is invocated from base.Parse() 
			base.Parse (node2Parse);

			System.Xml.XmlNode node;

			for ( int i=0; i<node2Parse.Attributes.Count; i++)
			{
				node = node2Parse.Attributes[i];

				switch ( node.Name )
				{
					case XMLDocumentTemplate.IDFORMAT_ATTRIBUTE:
						sIdFormat = node.InnerText;
						break; 
						//modified by e.leano for new version of DM: step 3
					case XMLDocumentTemplate.DOCUMENT_STORAGE_ATTRIBUTE:
						sDocumentStorage = node.InnerText;
						break; 
					
				}
			}
		}

		override public bOSdotNET.XML.XMLNode GetXMLNode()
		{
			bOSdotNET.XML.XMLNode xmlNode = base.GetXMLNode ();
			xmlNode.AddAttribute ( new bOSdotNET.XML.XMLAttribute (XMLDocumentTemplate.IDFORMAT_ATTRIBUTE, sIdFormat) );
			//modified by e.leano for new version of DM: step 3
			xmlNode.AddAttribute ( new bOSdotNET.XML.XMLAttribute (XMLDocumentTemplate.DOCUMENT_STORAGE_ATTRIBUTE, this.DocumentStorage) );

			return xmlNode;
		}
	}
}
